package gui;

import java.awt.Component;
import java.util.TreeMap;

import javax.swing.JTabbedPane;

public class TabManager {

	private JTabbedPane tb;
	private TreeMap<String, Integer> relacao;
	private Integer index;

	public TabManager() {
		tb = new JTabbedPane(JTabbedPane.TOP);
		relacao = new TreeMap<String, Integer>();
		index = 0;
	}

	public void addTab(String title, Component component) {
		tb.addTab(title, component);
		relacao.put(title, index);
		index++;
	}

	public void setEnabledAt(String title, boolean enabled) {
		Integer index = relacao.get(title);
		tb.setEnabledAt(index, enabled);
	}

	public void setSelectedTab(String title) {
		int index = relacao.get(title);
		tb.setSelectedIndex(index);
	}

	public JTabbedPane getJTabbedPane() {
		return tb;
	}

}
